package com.atguigu.srb.mq.config;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Component
public class AckMqConfig implements RabbitTemplate.ConfirmCallback,RabbitTemplate.ReturnCallback {
    @Resource
    RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init(){
        rabbitTemplate.setConfirmCallback(this);
        rabbitTemplate.setReturnCallback(this);
    }
    @Override
    public void confirm(CorrelationData correlationData, boolean b, String s) {
        System.out.println("消息发送成功");
    }

    @Override
    public void returnedMessage(Message message, int i, String s, String s1, String s2) {

        System.out.println("消息投递成功");
    }
}
